package main

import (
	"github.com/jasonlvhit/gocron"
	"hitme/go-api/logic/crontab"
	"hitme/go-api/modules/engine"
)

func main()  {
	engine.Default().AddConfigFromYAML("./config.yml")

	// Do jobs with params
	gocron.Every(1).Second().Do(crontab.TaskWithParams, 1, "hello")

	// Do jobs safely, preventing an unexpected panic from bubbling up
	//gocron.Every(1).Second().DoSafely(TaskWithParams, 1, "hello")

	// Do jobs without params
	gocron.Every(1).Second().Do(crontab.Task)
	//gocron.Every(2).Seconds().Do(task)
	//gocron.Every(1).Minute().Do(task)
	//gocron.Every(2).Minutes().Do(task)
	//gocron.Every(1).Hour().Do(task)
	//gocron.Every(2).Hours().Do(task)
	//gocron.Every(1).Day().Do(task)
	//gocron.Every(2).Days().Do(task)

	// Do jobs on specific weekday
	//gocron.Every(1).Monday().Do(task)
	//gocron.Every(1).Thursday().Do(task)

	// function At() take a string like 'hour:min'
	//gocron.Every(1).Day().At("10:30").Do(task)
	//gocron.Every(1).Monday().At("18:30").Do(task)

	// remove, clear and next_run
	//_, time := gocron.NextRun()
	//fmt.Println(time)

	//gocron.Remove(task)
	//gocron.Clear()

	// function Start start all the pending jobs
	<- gocron.Start()

	// also, you can create a new scheduler
	// to run two schedulers concurrently
	s := gocron.NewScheduler()
	//s.Every(3).Seconds().Do(task)
	<- s.Start()
}